var h5Url = 'http://localhost:8080/portals/vote/mobile/detail.jsp?id=';
var dateTypeName = '';
var defalutAwardsId = 0;
var defalutSendAwardsSubJson = null;
var defalutAwardsName = '';
var defalutAwardsDateType = 1;
var defalutParticipatorId = 0;
var onloading = false;
var defaultAwardArray = new Array();
var defaultSubAwardArray = new Array();

function tabFuc(this_){
    // 避免重复请求
    if (onloading) return;
    onloading = true;
    
    // 切换css
    $(".date_type").removeClass('bg');
    $(this_).addClass('bg');
	defalutAwardsDateType = $(this_).attr('date_type_val');
    if (defalutAwardsDateType == 1){
    	$(".tpShow").show();
	} else {
		$(".tpShow").hide();
	}
    defaultAwardArray = [];
    // 加载列表
    $("#voteAwardsNameList").empty();
    defalutAwardsDateType = $(this_).attr("date_type_val");
    $.ajaxSettings.async = true;
    var html='<div class="list-add" onClick = "toAddvoteAWards('+defalutAwardsDateType+')" > <span class="text" >新增评优 +</span> </div>';
    $.ajax({
        url: "/portals/vote/jsp/voteAwards/awardsList.jsp?dateType="+defalutAwardsDateType ,//请求路径
        type: "GET",//GET
        dataType: "JSON",// 
        async: false,
        success: function(obj) {
        	if(obj.code == 200){
        		var json = obj.data;
            	json.forEach(function(json){
            		defaultAwardArray.push(json);
    	        	html +='<div class="list-one" id="award_'+json.id+'" onclick="selectedVoteAwardsFunc(this)" date_type_val="'+json.dateType+'" awards_id="'+json.id+'" data_name="'+json.name+'">';
    	    	 	html +='<div class="single one"></div>';
    	    	 	html +='<span class="text">'+json.name+'</span>';
    	    	 	html +='</div>';
                })
        	}
        	
        },
        error: function(a,b,c) {
        }
    
    });
    $("#voteAwardsNameList").append(html);
    onloading = false;
    var lists = $(".list-one"); 
    if(lists.length>0){ 
    	 
    	selectedVoteAwardsFunc(lists.get(0))
    	 
    }else{
    	$(".rg-box").css('display','none');
    }
    
};

//弹出评优 type: 年度是1  ；季度是2
function toAddvoteAWards(dateType){
	  $(".rg-box").css('display','none');
	  $("#rg_box_addAward").css('display','block');
	  document.getElementById("dateType").value=dateType;
}
//评优 type: 年度是1  ；季度是2
function AddvoteAWards(type){
	$(".rg-box").css('display','none');
	$("#rg_box_addAward").css('display','block');
	let paramObj = new Object();
	paramObj.dateType = 	document.getElementById("dateType").value 
	paramObj.createType = 	2;
	if(isNullCheck(document.getElementById("awardName").value)){
		layer.msg("奖项名称不能为空");
		return ;
	}
	paramObj.name = document.getElementById("awardName").value 
	
	if(isNullCheck(document.getElementById("addstarttime").value)){
		layer.msg("开始时间不能为空");
		return ;
	}
	paramObj.startTime = 	document.getElementById("addstarttime").value 
	if(isNullCheck(document.getElementById("addendtime").value)){
		layer.msg("结束时间不能为空");
		return ;
	}
	paramObj.endTime = 		document.getElementById("addendtime").value 
	if(isNullCheck(document.getElementById("addAwardAbout").value)){
		layer.msg("活动说明不能为空");
		return ;
	}
	paramObj.about = document.getElementById("addAwardAbout").value 
	
	if(isNullCheck(document.getElementById("addAwardRegular").value)){
		layer.msg("奖项规则不能为空");
		return ;
	}
	paramObj.regular = 		document.getElementById("addAwardRegular").value
	if (defalutAwardsDateType==1){
		if(isNullCheck(document.getElementById("addVotes").value)){
			layer.msg("每个人可以投票数不能为空");
			return ;
		}
		if(document.getElementById("addVotes").value <=0){
			layer.msg("每个人可以投票数必须大于1");
			return ;
		}
		paramObj.votes = document.getElementById("addVotes").value
		if(isNullCheck(document.getElementById("addVoteSame").value)){
			layer.msg("同一人员允许投票数不能为空");
			return ;
		}
		if(document.getElementById("addVoteSame").value <=0){
			layer.msg("同一人允许投票数必须大于1");
			return ;
		}
		paramObj.votessame = 	document.getElementById("addVoteSame").value
	}
	if(checkDate(paramObj.startTime,paramObj.endTime)){
		layer.msg("开始时间不能大于结束时间");
		return ;
	}
	$.post("/portals/vote/jsp/voteAwards/add.jsp",paramObj,function (json) {
		 if(json.code==200){
			layer.msg("操作成功!");
	   		$("#rg_box_addAward").hide();
		 	if(defalutAwardsDateType==1){
		 		tabFuc(document.getElementById("year"));
		 	}else{
		 		tabFuc(document.getElementById("quarter"));
		 	}
		 	$("#addAwardForm").reset();
	   		$("#rg_box_addAward").css('display','none');
	 	}else{
	 		layer.msg("操作失败，原因："+json.msg);
	 	}
    });
}
/***
* 选中大奖项（动态加载右侧信息）
*/
function toEditAwrds(){
	var currentAwards  = getAwardById(defalutAwardsId);
	document.getElementById("editAwardsName").value = currentAwards.name==undefined?"": currentAwards.name
	document.getElementById("editaddstarttime").value = currentAwards.startTime==undefined?"": currentAwards.startTime
	document.getElementById("editaddendtime").value = currentAwards.endTime==undefined?"": currentAwards.endTime
	document.getElementById("editAbout").value = currentAwards.about==undefined?"": currentAwards.about
	document.getElementById("editRegular").value = currentAwards.regular ==undefined?"": currentAwards.regular
	if (defalutAwardsDateType==1){
		document.getElementById("editVoteNum").value = currentAwards.votes ==undefined?"": currentAwards.votes
		document.getElementById("editSameVoteNum").value = currentAwards.votessame  ==undefined?"": currentAwards.votessame
	}
	$('#mengban_pingyou').show(200)
}
function editAward(){
	
	
	let currentAwards  = getAwardById(defalutAwardsId);
	let index =  defaultAwardArray.indexOf(currentAwards);
	
	if(isNullCheck(document.getElementById("editAwardsName").value)){
		layer.msg("奖项名称不能为空");
		return ;
	}
	currentAwards.name = document.getElementById("editAwardsName").value ; 
	
	if(isNullCheck(document.getElementById("editaddstarttime").value)){
		layer.msg("开始时间不能为空");
		return ;
	}
	currentAwards.startTime = document.getElementById("editaddstarttime").value;  
	
	if(isNullCheck(document.getElementById("editaddendtime").value)){
		layer.msg("结束时间不能为空");
		return ;
	}
	currentAwards.endTime = document.getElementById("editaddendtime").value ;
	
	if(isNullCheck(document.getElementById("editAbout").value)){
		layer.msg("活动说明不能为空");
		return ;
	}
	currentAwards.about = document.getElementById("editAbout").value ;
	
	if(isNullCheck(document.getElementById("editRegular").value)){
		layer.msg("奖项规则不能为空");
		return ;
	}
	currentAwards.regular = document.getElementById("editRegular").value; 
	
	if(isNullCheck(document.getElementById("editVoteNum").value)){
		layer.msg("每个人可以投票数不能为空");
		return ;
	}
	if(document.getElementById("editVoteNum").value<=0){
		layer.msg("每个人可以投票数必须大于等于1");
		return ;
		
	}
	
	currentAwards.votes  = document.getElementById("editVoteNum").value ;
	if(isNullCheck(document.getElementById("editSameVoteNum").value)){
		layer.msg("同一人员允许投票数不能为空");
		return ;
	}
	
	if(document.getElementById("editSameVoteNum").value<=0){
		layer.msg("同一人员允许投票数必须大于等于1");
		return ;
	}
	currentAwards.votessame =   document.getElementById("editSameVoteNum").value;  
	
	if(checkDate(currentAwards.startTime,currentAwards.endTime)){
		layer.msg("开始时间不能大于结束时间");
		return ;
		
	}
	
	$.post("/portals/vote/jsp/voteAwards/update.jsp",currentAwards,function (json) {
	
		 if(json.code==200){
				layer.msg("操作成功!");
		   		$("#mengban_pingyou").hide();
		   		loadVoteAwardsInfo()
			 	if (index > -1) {
					defaultAwardArray.splice(index, 1);
				}
			 	defaultAwardArray.push(currentAwards)
			 	document.getElementById("editForm").reset();
	 	}else{
	 		layer.msg("操作失败，原因："+json.msg);
	 	}
   });
}
function selectedVoteAwardsFunc(this_) {
   // 避免重复请求
   if (onloading) return;
   onloading = true;
   $(".rg-box").css('display','none');
   $("#rg_box").css('display','block');
   // CSS 切换
   $(".list-one").removeClass('bg');
   $(this_).addClass('bg');
   // 奖项id
   defalutAwardsId = $(this_).attr("awards_id");
   // 获取父级数据类型
   defalutAwardsDateType = $(this_).attr("date_type_val");
   // 获取奖项信息
   dateTypeName = defalutAwardsDateType==1?'年度评优':'季度评优';
   defalutAwardsName = $(this_).attr("data_name");
   // 赋值奖项信息
   $("#dateTypeName").text(dateTypeName);
   $("#voteAwardsName").text(defalutAwardsName);
   // 奖项说明
   loadVoteAwardsInfo()
   loadSubAwardsData(defalutAwardsId,"");
   onloading = false;
}
function loadVoteAwardsInfo(){
	 $.ajaxSettings.async = false;
	   $.get("/portals/vote/jsp/voteAwards/info.jsp?id="+defalutAwardsId, function(obj){
		   var data = obj.data;
	       $("#voteAwardsAbout").html(typeof(data.about)==undefined?"":data.about);
	       $("#voteAwardsRegular").html(typeof(data.regular)==undefined?"":data.regular);
	       $("#voteAwardsStartTime").text(typeof(data.startTime)==undefined?"":data.startTime );
	       $("#voteAwardsEndTime").text(typeof(data.endTime)==undefined?"":data.endTime);
	   });
}

function defultValue(obj){
	if(typeof(obj)==undefined){
		return "";
	}
	return obj;
}

function toAddSubAward(){
	document.getElementById("subAwardTitle").data=0;
	$("#subAwardTitle").text("新增子奖项");
	$("#subAwardName").val("");
	document.getElementById("submitSubAwardbtn").value= "新增";
	$("#childrenSelect").show();
}
function subAwardsSearch(){
	var searchKey = $("#searchKey").val();
	loadSubAwardsData(defalutAwardsId,searchKey);
}

function loadSubAwardsData(defalutAwardsId,searchKey){
	defaultSubAwardArray=[];
	var subAwardList =$("#subAwardList");
 	var subTableHtml = '<tr class="tr-th"><th class="th">子奖项名称</th>   <th class="th">状态</th>   <th class="th">功能选项</th>  </tr>';
   $.get("/portals/vote/jsp/front/awardsSubData.jsp?awardsId="+defalutAwardsId+"&isPortal=isPortal&searchKey="+searchKey, function(objData){
	   var data = objData.data;
	   
       data.forEach(function(obj){
    	   var statusDesc = "";
    	   if(obj.status == 0){
    		   statusDesc = '待发布';
    	   }else if(obj.status == 1){
    		   statusDesc = '进行中';
    	   }else if(obj.status == -1){
    		   statusDesc = '已结束';
    	   }else{
    		   statusDesc = '已宣布获奖';
    	   }
    	   obj.awardsId = defalutAwardsId;
    	   defaultSubAwardArray.push(obj)
    	   var objstr  = JSON.stringify(obj); 
    	   subTableHtml += '<tr class="tr-td"> <td class="tdd"> <div class="td"> '+defultValue(obj.name)+'  </div>  </td>  <td class="tdd">   <div class="td">'+defultValue(statusDesc)+'</div> </td>'
    	   subTableHtml += '<td class="tdd tc"> <span class="inb">  <div class="td td-select"> ' 
    	   if(obj.status == 0){
    		   subTableHtml += '<div class="t "  onclick = "addMemberOrTeam(this)"  data='+objstr+' >提名人员或团队 </div>'
    		   subTableHtml += '<div class="t " onclick="showEdit(this)" data='+objstr+'>编辑  </div>'
    		   subTableHtml += '<div class="t " onclick ="toPublishVote(this)"  data='+objstr+'>发布</div>'
    		   subTableHtml += '<div class="t "  onclick="deleteSubAward(this)"  data='+objstr+' >删除 </div>'
    	   }
    	   if(obj.status == 1){
    		   subTableHtml += '<div class="t " onclick ="toFinishVote(this)"  data='+objstr+'>结束投票 </div>'
    		   subTableHtml += '<div class="t " onclick="showEdit(this)" data='+objstr+'>编辑  </div>'
    	   }
    	   if(obj.status == -1){
    		   subTableHtml += '<div class="t " onclick ="toDeclareVote(this)"  data='+objstr+'>发布获奖</div>'
//    		   subTableHtml += '<div class="t tstz"  onclick="toSendMsg(this)"  data='+objstr+' > 推送通知</div> '
    		   subTableHtml += '<div class="t "  onclick="deleteSubAward(this)" data='+objstr+' >删除 </div>'
    	   }
    	   if(obj.status == 2){
    		   subTableHtml += '<div class="t " onclick ="toDeclareVote(this)"  data='+objstr+'>查看获奖详情</div>'
    		   subTableHtml += '<div class="t tstz"  onclick="toSendMsg(this)"  data='+objstr+' > 推送通知</div>'
    		   subTableHtml += '<div class="t "  onclick="deleteSubAward(this)" data='+objstr+' >删除 </div>'
    	   }
    	   subTableHtml += '</span></td> </tr>';
       })
       subAwardList.empty();
       subAwardList.append(subTableHtml);
   });
	
}
function addSubAward(){
	var subArawdName = $("#subAwardName").val(); 
	if($.isEmptyObject(subArawdName) == true){
		layer.alert("奖项类型不能为空!")
		return ; 
	}
	var flagData = document.getElementById("subAwardTitle").data;
	if(0==flagData){
		$.post("/portals/vote/jsp/voteAwardsSub/add.jsp?name="+subArawdName+"&awardsId="+defalutAwardsId,function (json) {
			 if(json.code==200){
	    		 layer.msg("操作成功!");
	    		 $("#childrenSelect").hide();
		 		 loadSubAwardsData(defalutAwardsId,"")
	    	 }else{
	    		 layer.msg("操作失败，原因："+json.msg);
	    	 }
	     });
	}else{
		var subAwardsId =  document.getElementById("subAwardId").value
		$.post("/portals/vote/jsp/voteAwardsSub/update.jsp?name="+subArawdName+"&id="+subAwardsId+"&awardId="+defalutAwardsId,function (json) {
			 if(json.code==200){
	    		 layer.msg("操作成功!");
	    		 $("#childrenSelect").hide();
	    		 loadSubAwardsData(defalutAwardsId,"")
	    	 }else{
	    		 layer.msg("操作失败，原因："+json.msg);
	    	 }
	     });
	}
	/*校验去重*/ 
}

function showEdit(obj){
	 document.getElementById("subAwardTitle").data=1;
	 var dataObj = $.parseJSON($(obj).attr("data"));
	 $("#subAwardTitle").text("编辑子奖项信息");
	 $("#subAwardName").val(dataObj.name);
	 document.getElementById("subAwardId").value=dataObj.id;
	 document.getElementById("submitSubAwardbtn").value= "确认";
	 $("#childrenSelect").show();
}
function closeEditSubAward(){
	$("#childrenSelect").hide();
}

function toPublishVote(obj){
	var dataObj = $.parseJSON($(obj).attr("data"));
	document.getElementById("publicSubAwardId").value = dataObj.id
	$("#fabu-tp").show();
}
function closePublishVote(obj){
	$("#fabu-tp").hide();
}
function publishVote(){
	var subArawdsId = document.getElementById("publicSubAwardId").value; 
	var dataObj = getSubAwardById(subArawdsId);
	 $.post("/portals/vote/jsp/voteAwardsSub/send.jsp?id="+subArawdsId,function (json) {
		 if(json.code==200){
    		 layer.msg("操作成功!");
    		 $("#fabu-tp").hide();
    		 loadSubAwardsData(defalutAwardsId,"")
    	 }else{
    		 layer.msg("操作失败，原因："+json.msg);
    	 }
		 layer.close(ind);
     });
		 
}
var timer ;
function  toFinishVote(obj){
	var dataObj = $.parseJSON($(obj).attr("data"));
	var awardsObj = getAwardById(dataObj.awardsId);
	document.getElementById("finishSubAwardId").value = dataObj.id
	$(".js-tp").show();
	timer = setInterval("refreshTime("+Date.parse(awardsObj.endTime)+")",1000);
}

function refreshTime(endDate){
	var now = new Date();
	var urodz = new Date(endDate);//设定倒计时的时间
	now.setTime(now.getTime()+250);
	days = (urodz - now) / 1000 / 60 / 60 / 24;
	daysRound = Math.floor(days);
	hours = (urodz - now) / 1000 / 60 / 60 - (24 * daysRound);
	hoursRound = Math.floor(hours);
	minutes = (urodz - now) / 1000 /60 - (24 * 60 * daysRound) - (60 * hoursRound);
	minutesRound = Math.floor(minutes);
	seconds = (urodz - now) / 1000 - (24 * 60 * 60 * daysRound) - (60 * 60 * hoursRound) - (60 * minutesRound);
	secondsRound = Math.round(seconds);
	$("#jsday").text(daysRound);
	$("#jshour").text(hoursRound);
	$("#jsmin").text(minutesRound);
	$("#jssec").text(secondsRound); 
	
}
function  finishVote(){
	var subArawdsId =  document.getElementById("finishSubAwardId").value;
	var dataObj = getSubAwardById(subArawdsId);
	$.post("/portals/vote/jsp/voteAwardsSub/stop.jsp?id="+dataObj.id,function (json) {
		if(json.code==200){
			layer.msg("操作成功!");
			$("#childrenSelect").hide();
			loadSubAwardsData(defalutAwardsId,"")
		}else{
			layer.msg("操作失败，原因："+json.msg);
		}
	})
	
	cancelfinishVote();
}
function cancelfinishVote(){
	$("#jsday").text("");
	$("#jshour").text("");
	$("#jsmin").text("");
	$("#jssec").text("");
    $(".js-tp").hide("");
	clearInterval(timer);
}
function deleteSubAward(obj){
	 var dataObj = $.parseJSON($(obj).attr("data"));
	 layer.confirm('确定删除 '+dataObj.name+'?', {
		 title: "删除提示!",
		 btn: ['确定','取消'] //按钮
		 }, function(ind){
				 $.post("/portals/vote/jsp/voteAwardsSub/del.jsp?id="+dataObj.id,function (json) {
					 if(json.code==200){
			    		 layer.msg("操作成功!");
			    		 $("#childrenSelect").hide();
			    		 selectedVoteAwardsFunc(document.getElementById("award_"+defalutAwardsId));
			    	 }else{
			    		 layer.msg("操作失败，原因："+json.msg);
			    	 }
					 layer.close(ind);
			     });
		 }, function(inds){
		 layer.close(inds);
	 });
}

function toSendMsg(this_){
	defalutSendAwardsSubJson = JSON.parse($(this_).attr('data'));
	$(".ts-tz").show();
}

function sendMsg(){

	// 获取当前url
	var url = h5Url+defalutSendAwardsSubJson.id;
	// 消息
	var msg = '';
	switch (defalutSendAwardsSubJson.status*1) {
		case 1:
			msg ='['+defalutSendAwardsSubJson.name+']活动地址！'+url;
			break;
		case -1:
			msg ='['+defalutSendAwardsSubJson.name+']获奖公示地址！'+url;
			break;
		default:
			return
	}
	// 推送邮件
	var obj = new Object();
	obj.msgContent = msg;
	$.post('/vote/sendMail',obj,function (resp) {
		if (resp.code==200){
			layer.msg('推送成功')
			$(".ts-tz").hide(200);
		} else {
			layer.msg('推送失败')
			console.warn(resp.msg)
		}
	});
}
function closeSendMsg(){
	$(".ts-tz").hide();
}

function closeEditAward(){
	$('#mengban_pingyou').hide();
}

function isNullCheck(obj){
	if(typeof(obj)=='undefined'||obj.length==0){
		return true
	}
	return false ;
}
function checkDate(startDate,endDate){
		if (startDate.length > 0 && endDate.length > 0) {
			if (Date.parse(startDate.replace("-", "/")) > Date.parse(endDate.replace("-", "/"))) {
				return true;
			}
		}
		return false;
}



$(function() {

	$(".text-about").click(function(){
	    $(this).hide();
	    $(".text-intro-textarea-about").focus();
	})
	$(".text-regular").click(function(){
		$(this).hide();
		$(".text-intro-textarea-regular").focus();
	})
	// 初始化时，默认绑定‘是否有经济效益’的动态效果
	$("#isEconomic").click(function(){
		if($(isEconomic).is(':checked')){
			$("#saveMoneyShow").show(200);
		}else {
			$("#saveMoneyShow").hide(200);
		}
	})

	$(".date_type").removeClass('bg');
	$("#year").addClass('bg');
	tabFuc(document.getElementById("year"))
	
	// 团多提名人员按钮
    $('#tuandui').keypress(function(event){  
        if(event.which==13){ 
            let _this =  $(this);
            let val = _this.val();
            if(val){
                $("#tuanduiadd").append('<button type="button" class="layui-btn layui-btn-sm layui-btn-radius"> ${val} <span class="inb" style="width: 10px;">x</span></button>')
            _this.val('')
            }
        }  
      });
    $("#tuanduiadd").on('click','button',function(){
        $(this).remove();
    }) 
    // $(document).keyup(function(event){
    //     if(event.keyCode ==13){
    //         console.info()
    //     }
    // });


// 评优
//    $("#addPy").click(function(){
//        $('#mengban_pingyou').show()
//
//
//    })

    // 点击x后所有里面有的就会关闭弹框，做的时候注意自己设置关闭顺序
    $(".top-close").click(function(){
//        $('#mengban_pingyou').hide();
//        $("#childrenSelect").hide();
//        $(".fabu-tp").hide();
//     
//        $(".ts-tz").hide(); //tips-table
//        $(".tips-table").hide();
//        $(".tips-mile-text").hide();
//        $("#addtuandui").hide();
    })

    //子奖项
//    $(".addChildren").click(function(){
//    	console.log(this.data);
//       
//        
//        
//        
//    })

    //发布投票
//    $(".fabuTp").click(function(){
//        $(".fabu-tp").show();
//    })

     //推送通知
     $(".tsTz").click(function(){
        $(".ts-tz").show();
    })

 

    //发布获奖
    
//    $(".fp-hj").click(function(){
//        $(".fpHj").show();
//    })

    //删除子选项
//    $('.delet-children').click(function(){
//        $(".deletchildren").show();
//    })

 
    //删除提名
    $(".delet-tm").click(function(){
        $(".deletTm").show();
    })

    
    
    // 提名名单保存按钮（初始时，绑定新增方法）
    $("#addP").click(function(){
		$("#title").text("新增提名人员");
		$("#applicat").val('');
		$("#nominatorName").val('');
		$("#levelSecondDeptName").val('');
		$("#applicantPosition").val('');
		$("#nominatorSecondDeptName").val('');
		$("#nominatorPosition").val('');
		$("#levelSecondDeptName").val('');
		$("#applicantPosition").val('');
		$("#nominatorSecondDeptName").val('');
		$("#nominatorPosition").val('');
		$("#tuandui").val('');
		$("#imgsrc").val('');
		$("#uploadArea").attr('src','');
		$("#projectGoal").val('');
		$("#complete").val('');
		$("#influence").val('');
		$("#saveMoney").val(0);
		$("#isEconomic").prop("checked",false);
		$("#saveMoneyShow").hide();
		$("#nominatorProjectName").val('');
		$("#pojectNum").val('');
		$("#projectstarttime").val('');
		$("#projectendtime").val('');
		$("#subBtn").unbind();
		$("#subBtn").on("click",addVoteAwardsParticipatorFunc);
        $("#addtuandui").show(200);
    })
    
    $("#saveMoney").keyup(function(){
    	var c=$(this);
		var reg = /^[0-9]+(.[0-9]{2})?$/;
		if (!reg.test(c.val())) {
			$(this).val(0);
		}
    })

});

layui.use(['laydate', 'form','upload'], function(){
    const {laydate,form,upload } = layui;
    //普通图片上传 
    var uploadInst = upload.render({
        elem: '#uploadArea'
        ,url: '/portals/vote/voteFileUpLoad' //改成您自己的上传接口
        ,before: function(obj){
        	//预读本地文件示例，不支持ie8
	        obj.preview(function(index, file, result){
	            $('#uploadArea').attr('src', result); //图片链接（base64）
	            // $('#test1').hide()
	        });
        }
        ,done: function(res){
        //如果上传失败
	        if(res.code == 200){
	        	document.getElementById("imgsrc").value = res.data;
	            return layer.msg('上传成功');
	        }
        //上传成功
        }
        ,error: function(){
        //演示失败状态，并实现重传
        var demoText = $('#demoText');
        demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
        demoText.find('.demo-reload').on('click', function(){
            uploadInst.upload();
        });
        }
    });
    //监听指定开关
    form.on('switch(switchTest)', function(data){
        layer.msg('开关checked：'+ (this.checked ? 'true' : 'false'), {
        offset: '6px'
        });
        layer.tips('温馨提示：请注意开关状态的文字可以随意定义，而不仅仅是ON|OFF', data.othis)
    });
    // 团队个人切换
//    form.on('radio(type)', function (data) {
//        if( data.elem.checked){　　　　　　//判断当前多选框是选中还是取消选中
////             if(data.value == '个人'){
////                $(".removegeren").show();
////                $(".removetuandui").hide();
////
////            }else{
////                $(".removegeren").hide();
////                $(".removetuandui").show();
////            }
//            
//        } 
//    　　  data.value;   //  当前选中的value值
//    });
        
    //提名个人
    laydate.render({ 
        elem: '#starttime'  ,type: 'datetime'
    });
    laydate.render({ 
        elem: '#endtime' ,type: 'datetime'
    });
    //新增评优
    laydate.render({ 
         elem: '#addstarttime' ,type: 'datetime'
    });
    laydate.render({ 
        elem: '#addendtime'  ,type: 'datetime'
    });
    //编辑评优
    laydate.render({ 
    	elem: '#editaddstarttime' ,type: 'datetime'
    });
    laydate.render({ 
    	elem: '#editaddendtime'  ,type: 'datetime'
    });
    //项目开始时间
    laydate.render({ 
    	elem: '#projectstarttime' ,type: 'datetime'
    });
    //项目结束时间
    laydate.render({ 
    	elem: '#projectendtime'  ,type: 'datetime'
    });
    
});

function getAwardById(id){
	for(var i = 0; i < defaultAwardArray.length; i++){
		var data = defaultAwardArray[i]
		if(data.id == parseInt(id)){
			return data
		}
	}
	return null;
}



function getSubAwardById(id){
	for(var i = 0; i < defaultSubAwardArray.length; i++){
		var data = defaultSubAwardArray[i]
		if(data.id == parseInt(id)){
			return data
		}
	}
	return null;
}


/***
 * radio 切换
 */
function onchangeNominatorTypeFunc(this_) {
	var nominatorType = $(this_).val();
	if (nominatorType == 1){
		$(".removegeren").show();
		$(".removetuandui").hide();
		document.getElementById("nonPic").innerHTML('被提名人的照片：<span class="cred">*</span>')
	} else {
		$(".removegeren").hide();
		$(".removetuandui").show();
		document.getElementById("nonPic").innerHTML('被提名团队的照片：<span class="cred">*</span>')
	}
}

function searchParticipator(){
	let awardsSubnameId =  document.getElementById("awardsSubnameId").value
	loadParticipatorTable(awardsSubnameId)
}
/**
 * 提名团队列表
 * @param obj
 * @returns
 */
function addMemberOrTeam(obj){
	let subArardsInfo = JSON.parse($(obj).attr("data"));
	document.getElementById("awardsSubnameId").value=subArardsInfo.id;
	loadParticipatorTable(subArardsInfo.id);
	$("#show-people").show();
}

function loadParticipatorTable(awardsSubnameId){
	let searchkeyParticipator = document.getElementById("searchkeyParticipator").value;
	var listHtml='<thead> ';
	listHtml+='<tr class="tr-th"> ';
	listHtml += '<th class="th">提名类型</th>'
	listHtml += '<th class="th">提名项目名称</th>'
	listHtml += '<th class="th">被提名人姓名/成员</th>'
    /*listHtml += '<th class="th">被提名人/团队</th>'*/
    listHtml += '<th class="th">被提名人职位</th>'
    listHtml += '<th class="th">申请人 </th>'
    listHtml += '<th class="th">申请人职位 </th>'
    listHtml += '<th class="th">申请人部门</th>'
    listHtml += '<th class="th">票数</th>'
    listHtml += '<th class="th">小红花</th>'
    listHtml += '<th class="th">留言</th>'
    listHtml += '<th class="th">功能选项</th></tr>'
    listHtml += '</thead>'

    $.post("/portals/vote/jsp/voteAwardsParticipator/list.jsp?awardsSubnameId="+awardsSubnameId+"&searchKey="+searchkeyParticipator,function (json) {
	 if(json.code==200){
		 listHtml += '<tbody>'
		 json.data.forEach(function(data){
			 	 
					listHtml += '<tr class="tr-td">' 
					listHtml += '<td class="tdd"> <div class="td"> '+(data.nominatorType==1?'个人':'团队')+'  </div> </td>'
					listHtml += '<td class="tdd tc"> <div class="td">  </div> '+(data.nominatorProjectName==undefined?'-':data.nominatorProjectName)+' </td>'
					listHtml += '<td class="tdd tc">  <div class="td"> '+data.memberNames+' </div> </td>'
					listHtml += '<td class="tdd tc">  <div class="td"> '+(data.nominatorType==2?'-':data.nominatorPosition)+' </div> </td>'
					listHtml += '<td class="tdd tc"> <div class="td"> '+(data.applicantName==undefined?'-':data.applicantName)+' </div>  </td>'
					listHtml += '<td class="tdd tc"> <div class="td"> '+(data.nominatorType==2?'-':data.applicantPosition)+' </div>  </td>'
					listHtml += '<td class="tdd tc">   <div class="td">'+(data.nominatorType==2?'-':data.applicantDeptName)+' </div> </td>'
					listHtml += '<td class="tdd tc"> <div class="td"> '+data.votesNum+' </div> </td>'
					listHtml += '<td class="tdd tc"> <div class="td"> '+data.flowerNum+'</div> </td>'
					listHtml += '<td class="tdd tc">  <div class="td"> '+data.messageNum+'</div>  </td>'
					listHtml += '<td class="tdd tc">  <div class="td tc"> ' 
					listHtml += '	<div class="inb" style="width: 86px;">'
					listHtml += '		 <div class="fl mr30 c5f9dab curpointer addtuandui" onclick="editParticipator('+data.id+')" >编辑</div>'
					listHtml += '		 <div class="fl c5f9dab curpointer delet-tm" onclick="deleteParticipator('+data.id+')">  删除 </div>'
					listHtml += '</div> </div> </td> </tr>'
		 });
		 listHtml += '</tbody>'
	 }
    });
	 $("#teamPeopleList").empty()
	  $("#teamPeopleList").append(listHtml);
	  
 
}

/***
 * 关闭提名
 */
function closeVoteAwardsParticipatorFunc() {
	document.getElementById("addtuandui").style.display = "none";
}
/***
 * 关闭提名列表
 */
function closeShowPeopleList() {
	document.getElementById("show-people").style.display = "none";
}


/***
 * 新增提名人员信息
 */
function addVoteAwardsParticipatorFunc() {
	var obj = new Object();
	var nominatorType = $("input[name='nominatorType']:checked").val();
	obj.nominatorType = nominatorType;
	obj.applicantName = $("#applicat").val();
	if (obj.applicantName == undefined || obj.applicantName == ''){
		layer.msg("申请人姓名不能为空");
		return;
	}

	obj.applicantDeptName = $("#levelSecondDeptName").val();
	if (obj.applicantDeptName == undefined || obj.applicantDeptName == ''){
		layer.msg("申请人二级部门不能为空");
		return;
	}
	obj.applicantPosition = $("#applicantPosition").val();
	if (obj.applicantPosition == undefined || obj.applicantPosition == ''){
		layer.msg("申请人职位不能为空");
		return;
	}
	if (nominatorType == 1){
		obj.nominatorName = $("#nominatorName").val();
		if (obj.nominatorName == undefined || obj.nominatorName == ''){
			layer.msg("被提名人姓名不能为空");
			return;
		}
		obj.nominatorDeptName = $("#nominatorSecondDeptName").val();
		if (obj.nominatorDeptName == undefined || obj.nominatorDeptName == ''){
			layer.msg("被提名人二级部门不能为空");
			return;
		}
		obj.nominatorPosition = $("#nominatorPosition").val();
		if (obj.nominatorPosition == undefined || obj.nominatorPosition == ''){
			layer.msg("被提名人职位不能为空");
			return;
		}
	} else {
		obj.tuandui = $("#tuandui").val();
		if (obj.tuandui == undefined || obj.tuandui == ''){
			layer.msg("提名团队成员姓名不能为空");
			return;
		}
	}
	obj.nominatorPhoto = $("#imgsrc").val();
	if (obj.nominatorPhoto == undefined || obj.nominatorPhoto == ''){
		layer.msg("被提名人的照片不能为空");
		return;
	}
	obj.projectGoal = $("#projectGoal").val();
	if (obj.projectGoal == undefined || obj.projectGoal == ''){
		layer.msg("方案目标不能为空");
		return;
	}
	obj.complete = $("#complete").val();
	if (obj.complete == undefined || obj.complete == ''){
		layer.msg("做了什么业绩不能为空");
		return;
	}
	obj.influence = $("#influence").val();
	if (obj.influence == undefined || obj.influence == ''){
		layer.msg("成就/影响不能为空");
		return;
	}
	obj.saveMoney = $("#saveMoney").val();// 节约金额
	if($(isEconomic).is(':checked')){
		obj.isEconomic = 1;// 是否有经济效益
	}else{
		obj.isEconomic = 0
	}
	obj.nominatorProjectName = $("#nominatorProjectName").val();
	if (obj.nominatorProjectName == undefined || obj.nominatorProjectName == ''){
		layer.msg("项目名称不能为空");
		return;
	}
	obj.pojectNum = $("#pojectNum").val();
	if (obj.pojectNum == undefined || obj.pojectNum == ''){
		layer.msg("项目号不能为空");
		return;
	}
	obj.pojectStartTime = $("#projectstarttime").val();
	if (obj.pojectStartTime == undefined || obj.pojectStartTime == ''){
		layer.msg("项目开始时间不能为空");
		return;
	}
	obj.pojectEndTime = $("#projectendtime").val();
	if (obj.pojectEndTime == undefined || obj.pojectEndTime == ''){
		layer.msg("项目结束时间不能为空");
		return;
	}
	obj.awardsSubnameId = document.getElementById("awardsSubnameId").value;
	if (obj.awardsSubnameId == undefined){
		layer.msg("awardsSubnameId不能为空");
		return;
	}
	obj.nominatorStatus = 1;
	// 新增数据
	if (onloading) return;
	onloading = true;
	console.table(obj)
	$.post("/portals/vote/jsp/voteAwardsParticipator/add.jsp", obj, function(resp){
		if (resp.code == 200){
			layer.msg("操作成功");
			$("#addtuandui").hide(200);
			// 重新加载列表
			loadParticipatorTable(obj.awardsSubnameId);
		} else if (resp.msg=='请重新登录'){
			layer.msg("请重新登录");
		}else {
			console.error(resp.msg)
		}
	});
	onloading = false;
}

/****
 * 编辑提名人员信息
 */
function updVoteAwardsParticipatorFunc() {
	var obj = new Object();
	var nominatorType = $("input[name='nominatorType']:checked").val();
	obj.id = defalutParticipatorId;
	obj.nominatorType = nominatorType;
	obj.applicantName = $("#applicat").val();
	if (obj.applicantName == undefined || obj.applicantName == ''){
		layer.msg("申请人姓名不能为空");
		return;
	}
	obj.applicantDeptName = $("#levelSecondDeptName").val();
	if (obj.applicantDeptName == undefined || obj.applicantDeptName == ''){
		layer.msg("申请人二级部门不能为空");
		return;
	}
	obj.applicantPosition = $("#applicantPosition").val();
	if (obj.applicantPosition == undefined || obj.applicantPosition == ''){
		layer.msg("申请人职位不能为空");
		return;
	}
	if (nominatorType == 1){
		obj.nominatorName = $("#nominatorName").val();
		if (obj.nominatorName == undefined || obj.nominatorName == ''){
			layer.msg("被提名人姓名不能为空");
			return;
		}
		obj.nominatorDeptName = $("#nominatorSecondDeptName").val();
		if (obj.nominatorDeptName == undefined || obj.nominatorDeptName == ''){
			layer.msg("被提名人二级部门不能为空");
			return;
		}
		obj.nominatorPosition = $("#nominatorPosition").val();
		if (obj.nominatorPosition == undefined || obj.nominatorPosition == ''){
			layer.msg("被提名人职位不能为空");
			return;
		}
	} else {
		obj.tuandui = $("#tuandui").val();
		if (obj.tuandui == undefined || obj.tuandui == ''){
			layer.msg("提名团队成员姓名不能为空");
			return;
		}
	}
	obj.nominatorPhoto = $("#imgsrc").val();
	if (obj.nominatorPhoto == undefined || obj.nominatorPhoto == ''){
		layer.msg("被提名人的照片不能为空");
		return;
	}
	obj.projectGoal = $("#projectGoal").val();
	if (obj.projectGoal == undefined || obj.projectGoal == ''){
		layer.msg("方案目标不能为空");
		return;
	}
	obj.complete = $("#complete").val();
	if (obj.complete == undefined || obj.complete == ''){
		layer.msg("做了什么业绩不能为空");
		return;
	}
	obj.influence = $("#influence").val();
	if (obj.influence == undefined || obj.influence == ''){
		layer.msg("成就/影响不能为空");
		return;
	}
	obj.saveMoney = $("#saveMoney").val();// 节约金额
	if($(isEconomic).is(':checked')){
		obj.isEconomic = 1;// 是否有经济效益
	}else{
		obj.isEconomic = 0
	}
	obj.nominatorProjectName = $("#nominatorProjectName").val();
	if (obj.nominatorProjectName == undefined || obj.nominatorProjectName == ''){
		layer.msg("项目名称不能为空");
		return;
	}
	obj.pojectNum = $("#pojectNum").val();
	if (obj.pojectNum == undefined || obj.pojectNum == ''){
		layer.msg("项目号不能为空");
		return;
	}
	obj.pojectStartTime = $("#projectstarttime").val();
	if (obj.pojectStartTime == undefined || obj.pojectStartTime == ''){
		layer.msg("项目开始时间不能为空");
		return;
	}
	obj.pojectEndTime = $("#projectendtime").val();
	if (obj.pojectEndTime == undefined || obj.pojectEndTime == ''){
		layer.msg("项目结束时间不能为空");
		return;
	}
	obj.awardsSubnameId = document.getElementById("awardsSubnameId").value;
	if (obj.awardsSubnameId == undefined){
		layer.msg("awardsSubnameId不能为空");
		return;
	}

	// 编辑数据
	if (onloading) return;
	onloading = true;
	console.table(obj)
	$.post("/portals/vote/jsp/voteAwardsParticipator/update.jsp", obj, function(resp){
		if (resp.code == 200){
			layer.msg("操作成功");
			$("#addtuandui").hide(200);
			// 重新加载列表
			loadParticipatorTable(obj.awardsSubnameId);
		} else if (resp.msg=='请重新登录'){
			layer.msg("请重新登录");
		}else {
			console.error(resp.msg)
		}
	});
	onloading = false;
}

/**
 *  填充提名人员信息（待编辑）
 */
function editParticipator(id){
	// 填充资料
	defalutParticipatorId = id;
	if (onloading) return;
	onloading = true;
	$.get("/portals/vote/jsp/voteAwardsParticipator/info.jsp?id="+id,function (resp) {
		if (resp.code == 200){
			var data = resp.data;
			if (data == undefined) {
				layer.msg("未找到相关数据");
			}else {
				$("input[name='nominatorType'][value='"+data.nominatorType+"']").attr("checked",true);
				$("#applicat").val(data.applicantName);
				$("#nominatorName").val(data.nominatorName);
				$("#levelSecondDeptName").val(data.applicantDeptName);
				$("#applicantPosition").val(data.applicantPosition);
				$("#nominatorSecondDeptName").val(data.nominatorDeptName);
				$("#nominatorPosition").val(data.nominatorPosition);
				$("#levelSecondDeptName").val(data.applicantDeptName);
				$("#applicantPosition").val(data.applicantPosition);
				$("#nominatorSecondDeptName").val(data.nominatorDeptName);
				$("#nominatorPosition").val(data.nominatorPosition );
				$("#tuandui").val(data.memberNames);
				if (data.nominatorType == 1){
					$(".removegeren").show();
					$(".removetuandui").hide();
				} else {
					$(".removegeren").hide();
					$(".removetuandui").show();
				}
				$("#imgsrc").val(data.nominatorPhoto);
				$("#uploadArea").attr('src',data.nominatorPhoto);
				$("#projectGoal").val(data.projectGoal);
				$("#complete").val(data.complete);
				$("#influence").val(data.influence);
				if (undefined == data.saveMoney) {
					$("#saveMoney").val(0);
				}else {
					$("#saveMoney").val(data.saveMoney);
				}
				if (undefined != data.isEconomic && data.isEconomic) {
					$("#isEconomic").prop("checked",true);
					$("#saveMoneyShow").show();
				}else {
					$("#isEconomic").prop("checked",false);
					$("#saveMoneyShow").hide();
				}
				$("#nominatorProjectName").val(data.nominatorProjectName);
				$("#pojectNum").val(data.pojectNum);
				$("#projectstarttime").val(data.pojectStartTime);
				$("#projectendtime").val(data.pojectEndTime);
				$("#awardsSubnameId").val(data.awardsSubnameId);
				$("#title").text("编辑提名人员");
				$("#addtuandui").show(200);
			}
			$("#subBtn").unbind();
			$("#subBtn").on("click",updVoteAwardsParticipatorFunc);
		} else {
			console.error(resp.msg)
		}
	});
	onloading = false;
}
/**
 * 删除提名人员信息
 */
function deleteParticipator(id){
	$.get("/portals/vote/jsp/voteAwardsParticipator/del.jsp?id="+id,function (resp) {
		if(resp.code ==200){
			layer.msg("删除成功!");
			let awardsSubnameId =  document.getElementById("awardsSubnameId").value
			loadParticipatorTable(awardsSubnameId)
		}
	})
}

function toDeclareVote(obj){
	let subArardsInfo = JSON.parse($(obj).attr("data"));
	document.getElementById("declareAwardsSubnameId").value = subArardsInfo.id;
	var awardsSubnameId =  subArardsInfo.id
	loadDeclareVoteList(awardsSubnameId);
	 $("#fbhj").show();
}

function searckDeclareAwards(){
	var awardsSubnameId  = document.getElementById("declareAwardsSubnameId").value
	loadDeclareVoteList(awardsSubnameId);
}

function loadDeclareVoteList(awardsSubnameId){
	var   listHtml =""
	let searchkeyParticipator = document.getElementById("declareAwardsKeyWords").value;
	    	  $.post("/portals/vote/jsp/voteAwardsParticipator/list.jsp?awardsSubnameId="+awardsSubnameId+"&searchKey="+searchkeyParticipator,function (json) {
	    			 if(json.code==200){
	    				 var datas  = json.data;
	    				 if (datas == undefined) {
	    						layer.msg("未找到相关数据");
	    					}else {
	    						//已发布获奖
	    						if(json.awardSubStatus == 2){
	    							      listHtml ='<tr class="tr-th">'
//	    								  listHtml +='<th class="th">选择</th>'
	    								  listHtml+='<th class="th">是否获奖</th>'
	    								  listHtml +='<th class="th">提名类型</th>'
	    							      listHtml+='<th class="th">提名项目名称</th>'
	    							      listHtml+='<th class="th">被提名人姓名/成员</th>'
	    							      listHtml+='<th class="th">被提名人职位</th>'
	    							      listHtml+='<th class="th">申请人</th>'
	    							      listHtml+='<th class="th">申请人职位 </th>'
	    							      listHtml+='<th class="th">申请人部门</th>'
	    							      listHtml+='<th class="th">票数</th>'
	    							      listHtml+='<th class="th">小红花</th>'
	    							      listHtml+='<th class="th">留言</th>'
	    							      listHtml+='</tr>'
	    							    	  datas.forEach(function(data){
	    							    		  	  listHtml += '<tr class="tr-td">' 
//	    							    			  listHtml += '<td class="tdd"> <div class="td"><input type="checkbox" name="arwadCheckBox" id="'+data.id+'">  </div>   </td>' 
	    							    			  listHtml += '<td class="tdd"> <div class="td"> '+(data.winStatus==1?'获奖':'未获奖')+'  </div> </td>'
	    							    			  listHtml += '<td class="tdd"> <div class="td"> '+(data.nominatorType==1?'个人':'团队')+'  </div> </td>'
	    							    			  listHtml += '<td class="tdd tc"> <div class="td"> </div> '+data.nominatorProjectName+' </td>'
	    							    			  listHtml += '<td class="tdd tc">  <div class="td"> '+data.memberNames+' </div> </td>'
	    							    			  listHtml += '<td class="tdd tc">  <div class="td"> '+(data.nominatorType==1?data.nominatorPosition:'-')+' </div> </td>'
	    							    			  listHtml += '<td class="tdd tc"> <div class="td"> '+data.applicantName+' </div>  </td>'
	    							    			  listHtml += '<td class="tdd tc"> <div class="td"> '+data.applicantPosition+' </div>  </td>'
	    							    			  listHtml += '<td class="tdd tc">   <div class="td">'+data.applicantDeptName+' </div> </td>'
	    							    			  listHtml += '<td class="tdd tc"> <div class="td"> '+data.votesNum+' </div> </td>'
	    							    			  listHtml += '<td class="tdd tc"> <div class="td"> '+data.flowerNum+'</div> </td>'
	    							    			  listHtml += '<td class="tdd tc">  <div class="td"> '+data.messageNum+'</div></td></tr>'
	    							    			  
	    							    	  });
	    							document.getElementById("isShowDeclearFunc").style.display="none";
	    						}else{//未发布获奖
	    							      listHtml ='<tr class="tr-th">'
	    								  listHtml +='<th class="th">选择</th>'
	    								  listHtml +='<th class="th">提名类型</th>'
	    							      listHtml+='<th class="th">提名项目名称</th>'
	    							      listHtml+='<th class="th">被提名人姓名/成员</th>'
	    							      listHtml+='<th class="th">被提名人职位</th>'
	    							      listHtml+='<th class="th">申请人 </th>'
	    							      listHtml+='<th class="th">申请人职位 </th>'
	    							      listHtml+='<th class="th">申请人部门</th>'
	    							      listHtml+='<th class="th">票数</th>'
	    							      listHtml+='<th class="th">小红花</th>'
	    							      listHtml+='<th class="th">留言</th>'
	    							      listHtml+='</tr>'
	    							    	  datas.forEach(function(data){
	    			    							listHtml += '<tr class="tr-td">' 
	    		    								listHtml += '<td class="tdd"> <div class="td"><input type="checkbox" name="arwadCheckBox" id="'+data.id+'">  </div>   </td>' 
	    			    							listHtml += '<td class="tdd"> <div class="td"> '+(data.nominatorType==1?'个人':'团队')+'  </div> </td>'
	    			    							listHtml += '<td class="tdd tc"> <div class="td"> </div> '+data.nominatorProjectName+' </td>'
	    			    							listHtml += '<td class="tdd tc">  <div class="td"> '+data.memberNames+' </div> </td>'
	    			    							listHtml += '<td class="tdd tc">  <div class="td"> '+(data.nominatorType==1?data.nominatorPosition:'-')+' </div> </td>'
	    			    							listHtml += '<td class="tdd tc"> <div class="td"> '+data.applicantName+' </div>  </td>'
	    			    							listHtml += '<td class="tdd tc"> <div class="td"> '+data.applicantPosition+' </div>  </td>'
	    			    							listHtml += '<td class="tdd tc">   <div class="td">'+data.applicantDeptName+' </div> </td>'
	    			    							listHtml += '<td class="tdd tc"> <div class="td"> '+data.votesNum+' </div> </td>'
	    			    							listHtml += '<td class="tdd tc"> <div class="td"> '+data.flowerNum+'</div> </td>'
	    			    							listHtml += '<td class="tdd tc">  <div class="td"> '+data.messageNum+'</div></td></tr>'
	    			    							
	    			    						});
	    							      document.getElementById("isShowDeclearFunc").style.display="block";
	    						}
	    						
	    					}
	    			 }
	    		    });
	 $("#awardTable").empty()
	 $("#awardTable").append(listHtml);
	
	
}
//发布获奖
function declareVote(obj){
 
//	var idsCheckBoxs = document.getElementsByName("arwadCheckBox");
//	idsCheckBoxs.forEach(function(o){
//		
//	})
//	$("input[name='nominatorType']:checked").val()
	let ids = "";
	 $("input[name='arwadCheckBox']:checked").each(function (index, item) {
		 ids += $(this).attr("id")+",";
	    });
	 if(ids.length<=0){
		 layer.msg("请选择需要获奖的人员信息!");
		 return ;
	 }
	 ids = ids.substr(0,ids.length-1)
	 var awardsSubnameId  = document.getElementById("declareAwardsSubnameId").value
	 $.post("/portals/vote/jsp/voteAwardsParticipator/sendWin.jsp?ids="+ids+"&awardsSubnameId="+awardsSubnameId,function (json) {
		 if(json.code == 200){
			 layer.msg("获奖结果发布成功!");
			 closeDeclareVote();
		 }
	 })
}
function closeDeclareVote(){
	$("#fbhj").hide();
}